<?php
	session_start();
	require_once("../db_connect.php");

	$main_category_id  = htmlspecialchars($_POST['main_category_id'],ENT_QUOTES,"UTF-8");
	$main_category_name  = htmlspecialchars($_POST['main_category_name'],ENT_QUOTES,"UTF-8");

	$sql = "UPDATE category
			SET main_category_name = ?
			WHERE main_category_id = ?";

	$stmt = $db->prepare($sql);

	$data = array($main_category_name,
	              $main_category_id);

	$res =& $db->execute($stmt, $data);	//SQLを実行して、結果を $res に代入
	if (PEAR::isError($res)) {			//SQLの実行に失敗すればここでエラー文を出力
		die($res->getMessage());
	}

	header("Location: manage_main_category.php");
?>